﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace RainDrops
{
    class Player
    {
        private Rectangle bounds;
        public DropManager dropManager;
        public Player player;
        public int score;

        public Player(Rectangle bounds, DropManager dropManager)
        {
            this.bounds = bounds;
            this.dropManager = dropManager;
            this.score = 0;
        }

        private void HandleMouseInput(MouseState mouseState)
        {
            int mousex = ((mouseState.X));
            int mousey = ((mouseState.Y));

            if ((mousex >= 0) && (mousex < bounds.Width) && (mousey >= 0) && (mousey < bounds.Height))
            {
                if (mouseState.LeftButton == ButtonState.Pressed)
                {
                    // TODO: determine if and what drop object the player is clicking on
                    dropClick(new Vector2(mousex, mousey));
                }
            }
        }

        public void dropClick(Vector2 mousePos)
        {
            Rectangle fullMousePos = new Rectangle((int)mousePos.X, (int)mousePos.Y, 2, 2);
            for(int i=0; i > dropManager.Drops.Count; i++)
            {
                // TODO: find way to do collision detecting for mouse on rectangle
                if ((dropManager.Drops[i].IsCircleColliding(mousePos, 1.0f)) && (dropManager.Drops[i].onScreen(dropManager.Drops[i]) == true))
                {
                    dropManager.DropDown(dropManager.Drops[i]);

                }
                else { }
            }

        }

        public void Update(GameTime gameTime)
        {
            HandleMouseInput(Mouse.GetState());
        }
    }
}
